angular.module('app.service', ['ngResource']).
    factory('Rest', function($resource){


        return $resource('api/rest/:method/:id1/:id2', {}, {
                getCurrentCardHolder: {method:'GET', params:{method:'getCurrentCardHolder'}, isArray:false},
                authenticate: {method:'PUT', params:{method:'authenticate'}, isArray:false},
                logout: {method: 'PUT', params: {method: 'logout'},isArray: false},
                getVisulizationData: {method:'GET', params:{method:'getVisulizationData'}, isArray:false},
                addFundToCurrentCardHolder: {method: 'PUT', params: {method: 'addFundToCurrentCardHolder'}, isArray: false},
                addCardHolderTracker: {method: 'PUT', params: {method: 'addCardHolderTracker'}, isArray: false},
                getAllCafes : {method:'GET', params:{method:'getAllCafes'}, isArray:false},
                getCafeMenusByCafeId : {method:'GET', params:{method:'getCafeMenusByCafeId'}, isArray:false},
                getCafeById : {method:'GET', params:{method:'getCafeById'}, isArray:false},
                getReviewsByCafeId :  {method:'GET', params:{method:'getReviewsByCafeId'}, isArray:false},
                addUserReview: {method: 'PUT', params: {method: 'addUserReview'}, isArray: false}



            }

        );





    }).factory('eventBroadcast', function($rootScope) {
        // eventBroadcaster is the object created by the factory method.
        var eventBroadcaster = {};

        // The message is a string or object to carry data with the event.
        eventBroadcaster.message = '';

        // The event name is a string used to define event types.
        eventBroadcaster.eventName = '';

        // This method is called from within a controller to define an event and attach data to the eventBroadcaster object.
        eventBroadcaster.broadcast = function(evName, msg) {
            this.message = msg;
            this.eventName = evName;
            this.broadcastItem();
        };

        // This method broadcasts an event with the specified name.
        eventBroadcaster.broadcastItem = function() {
            $rootScope.$broadcast(this.eventName);
        };

        return eventBroadcaster; })